import { defineAsyncComponent } from 'vue'; //异步组挂载器

import { createRouter, createWebHashHistory, createWebHistory, RouteRecordRaw, Router } from 'vue-router'
import { useGlobalVars } from '@/utils/variables'
import docs from './docs'

const { BaseRouter } = useGlobalVars()

// 路由配置
const routes: RouteRecordRaw[] = [
  // {
  //   path: '/:pathMatch(.*)*',
  //   redirect: { name: 'Layout' }
  // },
  {
    path: '/docs',
    name: 'Layout',
    component: defineAsyncComponent(() => import(`@/views/layout/index.vue`))
  },
  {
    path: '/doc',
    redirect: {
      name: 'introduce'
    },
    component: defineAsyncComponent(() => import(`@/views/doc/index.vue`)),
    children: docs as any[]
  },
  {
    path: '/',
    component: defineAsyncComponent(() => import(`@/layouts/index.vue`)),
    redirect: '/map',
    // component: defineAsyncComponent(() => import(`@/views/examples/mainView.vue`))
    children: [
      {
        path: '/map',
        component: defineAsyncComponent(() => import(`@/views/home/map.vue`)),
      }
    ]

  },
  // 数据质量与监测能力分析分系统
  {
    path: '/dataMonitor',
    component: defineAsyncComponent(() => import(`@/applications/dataMonitor/views/index.vue`)),
    redirect: '/monitorMap',
    children: [
      {
        path: '/monitorMap',
        component: defineAsyncComponent(() => import(`@/applications/dataMonitor/views/map.vue`)),
      }
    ]
  },
  // 数据公报与服务分系统
  {
    path: '/dataServer',
    component: defineAsyncComponent(() => import(`@/applications/dataServer/views/index.vue`)),
    redirect: '/serverMap',
    children: [
      {
        path: '/serverMap',
        component: defineAsyncComponent(() => import(`@/applications/dataServer/views/map.vue`)),
      }
    ]
  },
  {
    path: '/example',
    component: defineAsyncComponent(() => import(`@/views/examples/mainView.vue`))
  }
]

// 路由实例
const router: Router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
